home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / redakcyjne / programy / FEBE (Firefox Environment Backup Extension) 5.0 / febe-5.0-fx.xpi / chrome / febe.jar / content / febeOptions.js < prev    next >
Text File  |  2007-06-20  |  25KB  |  612 lines

  1. // author: Chuck Baker
  2. // contact: febe@customsoftwareconsult.com
  3. // Version 5.0
  4.     
  5.     window.addEventListener("load",febeBuProfileCheck,true);
  6.  
  7. function febeBuSelectAll() {
  8.     document.getElementById("buExtensions_id").setAttribute("checked",true);
  9.     document.getElementById("buThemes_id").setAttribute("checked",true);
  10.     document.getElementById("buBookmarks_id").setAttribute("checked",true);
  11.     document.getElementById("buPreferences_id").setAttribute("checked",true);
  12.     document.getElementById("buCookies_id").setAttribute("checked",true);
  13.     document.getElementById("buUserChrome_id").setAttribute("checked",true);
  14.     document.getElementById("buUserContent_id").setAttribute("checked",true);
  15.     document.getElementById("buUserPwd_id").setAttribute("checked",true);
  16.     document.getElementById("buPhishingData_id").setAttribute("checked",true);
  17.     document.getElementById("buSearchPlugins_id").setAttribute("checked",true);
  18.     document.getElementById("buBrowserHistory_id").setAttribute("checked",true);
  19.     document.getElementById("buFormFillHistory_id").setAttribute("checked",true);
  20.     document.getElementById("buPermissions_id").setAttribute("checked",true);
  21.     document.getElementById("buUDBu_id").setAttribute("checked",true);
  22.  
  23.     febePrefs.setBoolPref("extensions.febe.buExtensions",true);
  24.     febePrefs.setBoolPref("extensions.febe.buThemes",true);
  25.     febePrefs.setBoolPref("extensions.febe.buBookmarks",true);
  26.     febePrefs.setBoolPref("extensions.febe.buPreferences",true);
  27.     febePrefs.setBoolPref("extensions.febe.buCookies",true);
  28.     febePrefs.setBoolPref("extensions.febe.buUserChrome",true);
  29.     febePrefs.setBoolPref("extensions.febe.buUserContent",true);
  30.     febePrefs.setBoolPref("extensions.febe.buUserPwd",true);
  31.     febePrefs.setBoolPref("extensions.febe.buPhishingData",true);
  32.     febePrefs.setBoolPref("extensions.febe.buSearchPlugins",true);
  33.     febePrefs.setBoolPref("extensions.febe.buBrowserHistory",true);
  34.     febePrefs.setBoolPref("extensions.febe.buFormFillHistory",true);
  35.     febePrefs.setBoolPref("extensions.febe.buPermissions",true);
  36.     febePrefs.setBoolPref("extensions.febe.buUDBu",true);
  37.     return true;
  38. }//febeBuSelectAll()
  39.  
  40. function febeBuDeSelectAll(){
  41.     document.getElementById("buExtensions_id").setAttribute("checked",false);
  42.     document.getElementById("buThemes_id").setAttribute("checked",false);
  43.     document.getElementById("buBookmarks_id").setAttribute("checked",false);
  44.     document.getElementById("buPreferences_id").setAttribute("checked",false);
  45.     document.getElementById("buCookies_id").setAttribute("checked",false);
  46.     document.getElementById("buUserChrome_id").setAttribute("checked",false);
  47.     document.getElementById("buUserContent_id").setAttribute("checked",false);
  48.     document.getElementById("buUserPwd_id").setAttribute("checked",false);
  49.     document.getElementById("buPhishingData_id").setAttribute("checked",false);
  50.     document.getElementById("buSearchPlugins_id").setAttribute("checked",false);
  51.     document.getElementById("buBrowserHistory_id").setAttribute("checked",false);
  52.     document.getElementById("buFormFillHistory_id").setAttribute("checked",false);
  53.     document.getElementById("buPermissions_id").setAttribute("checked",false);
  54.     document.getElementById("buUDBu_id").setAttribute("checked",false);
  55.  
  56.     febePrefs.setBoolPref("extensions.febe.buExtensions",false);
  57.     febePrefs.setBoolPref("extensions.febe.buThemes",false);
  58.     febePrefs.setBoolPref("extensions.febe.buBookmarks",false);
  59.     febePrefs.setBoolPref("extensions.febe.buPreferences",false);
  60.     febePrefs.setBoolPref("extensions.febe.buCookies",false);
  61.     febePrefs.setBoolPref("extensions.febe.buUserChrome",false);
  62.     febePrefs.setBoolPref("extensions.febe.buUserContent",false);
  63.     febePrefs.setBoolPref("extensions.febe.buUserPwd",false);
  64.     febePrefs.setBoolPref("extensions.febe.buPhishingData",false);
  65.     febePrefs.setBoolPref("extensions.febe.buSearchPlugins",false);
  66.     febePrefs.setBoolPref("extensions.febe.buBrowserHistory",false);
  67.     febePrefs.setBoolPref("extensions.febe.buFormFillHistory",false);
  68.     febePrefs.setBoolPref("extensions.febe.buPermissions",false);
  69.     febePrefs.setBoolPref("extensions.febe.buUDBu",false);
  70.     return true;
  71. }//febeBuDeselectAll()
  72.  
  73. function febeBuProfileCheck(){
  74.     febeSetMsgs();
  75.   // Disable options if profile backup is checked
  76.     var prefName = "extensions.febe.buType";
  77.     if(!febePrefs.prefHasUserValue(prefName)){
  78.         febePrefs.setCharPref(prefName,"selective");
  79.     }//if
  80.     var buType = febePrefs.getCharPref(prefName);
  81.  
  82.     if(buType == "profile"){
  83.         document.getElementById("buExtensions_id").setAttribute("disabled",true);
  84.         document.getElementById("buThemes_id").setAttribute("disabled",true);
  85.         document.getElementById("buBookmarks_id").setAttribute("disabled",true);
  86.         document.getElementById("buPreferences_id").setAttribute("disabled",true);
  87.         document.getElementById("buCookies_id").setAttribute("disabled",true);
  88.         document.getElementById("buUserChrome_id").setAttribute("disabled",true);
  89.         document.getElementById("buUserContent_id").setAttribute("disabled",true);
  90.         document.getElementById("buUserPwd_id").setAttribute("disabled",true);
  91.         document.getElementById("buPhishingData_id").setAttribute("disabled",true);
  92.         document.getElementById("buSearchPlugins_id").setAttribute("disabled",true);
  93.         document.getElementById("buBrowserHistory_id").setAttribute("disabled",true);
  94.         document.getElementById("buFormFillHistory_id").setAttribute("disabled",true);
  95.         document.getElementById("buPermissions_id").setAttribute("disabled",true);
  96.         document.getElementById("buUDBu_id").setAttribute("disabled",true);
  97.         document.getElementById("buSelectAll").setAttribute("disabled",true);
  98.         document.getElementById("buDeselectAll").setAttribute("disabled",true);
  99.     } else {
  100.         document.getElementById("buExtensions_id").setAttribute("disabled",false);
  101.         document.getElementById("buThemes_id").setAttribute("disabled",false);
  102.         document.getElementById("buBookmarks_id").setAttribute("disabled",false);
  103.         document.getElementById("buPreferences_id").setAttribute("disabled",false);
  104.         document.getElementById("buCookies_id").setAttribute("disabled",false);
  105.         document.getElementById("buUserChrome_id").setAttribute("disabled",false);
  106.         document.getElementById("buUserContent_id").setAttribute("disabled",false);
  107.         document.getElementById("buUserPwd_id").setAttribute("disabled",false);
  108.         document.getElementById("buPhishingData_id").setAttribute("disabled",false);
  109.         document.getElementById("buSearchPlugins_id").setAttribute("disabled",false);
  110.         document.getElementById("buBrowserHistory_id").setAttribute("disabled",false);
  111.         document.getElementById("buFormFillHistory_id").setAttribute("disabled",false);
  112.         document.getElementById("buPermissions_id").setAttribute("disabled",false);
  113.         document.getElementById("buUDBu_id").setAttribute("disabled",false);
  114.         document.getElementById("buSelectAll").setAttribute("disabled",false);
  115.         document.getElementById("buDeselectAll").setAttribute("disabled",false);
  116.     }//if
  117.     return true;
  118. }//febeBuProfileCheck()    
  119.  
  120. function febeSelBUDestDir(){
  121.   // Select backup destinaton directory
  122.     const nsIFilePicker = Components.interfaces.nsIFilePicker;
  123.     var fp = Components.classes["@mozilla.org/filepicker;1"]
  124.              .createInstance(nsIFilePicker);
  125.     fp.init(window, febeMsg[5], nsIFilePicker.modeGetFolder);
  126.     fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
  127.  
  128.     // Set default directory to current backup directory
  129.     if(febePrefs.prefHasUserValue("extensions.febe.extBUdir")){
  130.         extBUdir = febeGetUnicharPref("extensions.febe.extBUdir");
  131.         if(extBUdir != ""){
  132.             var dd = Components.classes["@mozilla.org/file/local;1"]
  133.                      .createInstance(Components.interfaces.nsILocalFile);
  134.             dd.initWithPath(extBUdir);
  135.             fp.displayDirectory = dd;
  136.         }//if
  137.     }//if
  138.     var rv = fp.show();
  139.     if (rv == nsIFilePicker.returnOK){
  140.         rv = fp.file;
  141.         extBUdir = rv.path;
  142.         febeSetUnicharPref("extensions.febe.extBUdir", extBUdir);
  143.         document.getElementById("DestDirID").value = extBUdir;
  144.         var d = document.getElementById("DestDirID");
  145.         d.setAttribute("value",extBUdir);
  146.     }//if
  147.     febeCheckBuDestDir();
  148.     return true;
  149. }//febeSelBUDestDir()
  150.  
  151. function febePickTmpDir(){
  152.   // Select a specified tmp directory
  153.     const nsIFilePicker = Components.interfaces.nsIFilePicker;
  154.     var fp = Components.classes["@mozilla.org/filepicker;1"]
  155.              .createInstance(nsIFilePicker);
  156.     fp.init(window, febeMsg[154], nsIFilePicker.modeGetFolder);
  157.     fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
  158.  
  159.     // Set default directory to current specified tmp directory
  160.     if(febePrefs.prefHasUserValue("extensions.febe.tmpSpecifyDirectory")){
  161.         var td = febeGetUnicharPref("extensions.febe.tmpSpecifyDirectory");
  162.         if(td != ""){
  163.             var dd = Components.classes["@mozilla.org/file/local;1"]
  164.                      .createInstance(Components.interfaces.nsILocalFile);
  165.             try{
  166.                 dd.initWithPath(td);
  167.                 fp.displayDirectory = dd;
  168.             } catch(e){;}
  169.         }//if
  170.     }
  171.     var rv = fp.show();
  172.     if (rv == nsIFilePicker.returnOK){
  173.         rv = fp.file;
  174.         rv.append("febe.tmp");
  175.         var td = rv.path;
  176.         febeSetUnicharPref("extensions.febe.tmpSpecifyDirectory", td);
  177.         document.getElementById("febeSpecifyTmpDirLocation").value = td;
  178.         var d = document.getElementById("febeSpecifyTmpDirLocation");
  179.         d.setAttribute("value",td);
  180.     }//if
  181.     return true;
  182. }//febePickTmpDir()
  183.  
  184.  
  185. function febeTmpDirCheck(){
  186.     var tdd = document.getElementById("febeDefaultTmpDirLocation").value;
  187.     var prefName = "extensions.febe.tmpDefaultDirectory";
  188.     febeSetUnicharPref(prefName,tdd);
  189.     var tsd = document.getElementById("febeSpecifyTmpDirLocation").value;
  190.     var prefName = "extensions.febe.tmpSpecifyDirectory";
  191.     febeSetUnicharPref(prefName,tsd);
  192.     
  193.     var tmpDirType = document.getElementById("febeTmpDirType").value;
  194.     switch(tmpDirType){
  195.         case "Default":        var whichDir = tdd;break;
  196.         case "Specified":     var whichDir = tsd;break;
  197.         default:            var whichDir = tdd;break;
  198.     }//switch
  199.     
  200.     var prefName = "extensions.febe.tmpDirectory";
  201.     var tmpdir = febeGetUnicharPref(prefName,whichDir);
  202.     febeTmpDirInfo();
  203.     return true;
  204. }//febeTmpDirCheck()
  205.  
  206. function febeTmpDirInfo(){
  207.     febeGetTmpDirectory(false);
  208.     var prefName = "extensions.febe.tmpDefaultDirectory";
  209.     document.getElementById("febeDefaultTmpDirLocation").value = febeGetUnicharPref(prefName);
  210.     var prefName = "extensions.febe.tmpSpecifyDirectory";
  211.     document.getElementById("febeSpecifyTmpDirLocation").value = febeGetUnicharPref(prefName);
  212.     var febeTmpStatus = "???";
  213.     if(!febeTmpDir.exists()){
  214.         febeTmpStatus = febeMsg[121];    // Does not exist
  215.         document.getElementById("deltmpdirbtn").disabled = true;
  216.         document.getElementById("viewtmpdirbtn").disabled = true;
  217.         document.getElementById("createtmpdirbtn").disabled = false;
  218.     }else{
  219.         document.getElementById("deltmpdirbtn").disabled = false;
  220.         document.getElementById("viewtmpdirbtn").disabled = false;
  221.         document.getElementById("createtmpdirbtn").disabled = true;
  222.         var entries = febeTmpDir.directoryEntries;
  223.         if(entries.hasMoreElements()){
  224.             febeTmpStatus = febeMsg[123];    // Exists with entries
  225.         }else{
  226.             febeTmpStatus = febeMsg[122];    // Exists, but empty
  227.         }//if
  228.     }//if
  229.     document.getElementById("febeTmpDirStatus").value = febeTmpStatus;
  230.     return true;
  231. }//febeTmpDirInfo()
  232.  
  233. function febeTmpDirOptions(){
  234.   // Set the active tmp directory
  235.     var type = document.getElementById("febeTmpDirType").value
  236.     switch(type){
  237.         case "Default": 
  238.             var prefName = "extensions.febe.tmpDefaultDirectory";
  239.             break;
  240.         case "Specified":
  241.             var prefName = "extensions.febe.tmpSpecifyDirectory";
  242.             break;
  243.     }//switch
  244.     var tmpdir = febeGetUnicharPref(prefName);    
  245.     var prefName = "extensions.febe.tmpDirectory";
  246.     febeSetUnicharPref(prefName,tmpdir);
  247.     febeTmpDirInfo();
  248.     return true;
  249. }//febeTmpDirOptions()
  250.  
  251. function febeClearTmpDir(){
  252.     // Get febe tmp directory information
  253.     febeGetTmpDirectory(false);
  254.     febeTmpDir.remove(true);
  255.     
  256.     var isDeleted = new Boolean(false);
  257.     isDeleted = !febeTmpDir.exists();
  258.     if(isDeleted){
  259.         febeAlert(febeMsg[124]);
  260.     }else{
  261.         febeAlert(febeMsg[125]);
  262.     }//if
  263.     febeTmpDirInfo();
  264.     return true;
  265. }//febeClearTmpDir()    
  266.  
  267. function febeViewTmpDir(){
  268.     febeOpenLink("file:///"+febeTmpDir.path);
  269.     return true;
  270. }//febeViewTmpDir()    
  271.  
  272. function febeCreateTmpDir(){
  273.     febeGetTmpDirectory(true);
  274.     febeTmpDirInfo();
  275.     febeAlert(febeMsg[130]);
  276.     return true;
  277. }//febeCreateTmpDir()
  278.  
  279. function febeClearPrefs(){
  280.     var ok = febeConfirm(febeMsg[126]+"\n"+febeMsg[127]+"\n\n"+febeMsg[128]);
  281.     if(!ok){return false;}
  282.     try {
  283.         var prefCount = {value:0}; 
  284.         var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); 
  285.         var prefBranch = prefService.getBranch(null); 
  286.         var prefArray = prefBranch.getChildList("extensions.febe." , prefCount); 
  287.         var nsIPrefBranch = Components.interfaces.nsIPrefBranch;  
  288.         for (i = 0; i < prefCount.value; i++){
  289.             if(prefBranch.prefHasUserValue(prefArray[i])){prefBranch.clearUserPref(prefArray[i]);}
  290.         }
  291.         prefBranch.deleteBranch("extensions.febe.");
  292.         
  293.         // delete the destination file if it exists
  294.         var febeDataFile = Components.classes["@mozilla.org/file/directory_service;1"]
  295.                  .getService(Components.interfaces.nsIProperties)
  296.                  .get("ProfD", Components.interfaces.nsIFile);
  297.         febeDataFile.append(FEBEDATAFILE);
  298.         if(febeDataFile.exists()){febeDataFile.remove(false);}
  299.     }catch (e) {
  300.         febeAlert(e);
  301.         return false;
  302.     }
  303.     var version = getFebeVersion();
  304.     var prefName = "extensions.febe.previousversion";
  305.     febePrefs.setCharPref(prefName,version);
  306.     febeAlert(febeMsg[129]);
  307.     febeRestartFx();
  308.     return true;
  309. }//febeClearPrefs()
  310.  
  311. function febeViewBuDir(){
  312.     var febeBuDestDir = document.getElementById("DestDirID").value;
  313.     febeOpenLink("file:///"+febeBuDestDir);
  314.     return true;
  315. }//febeViewBuDir()
  316.  
  317. function febeViewInstallDir(){
  318.     var febeInstallDir = document.getElementById("febeInstallPath").value;
  319.     febeOpenLink("file:///"+febeInstallDir);
  320.     return true;
  321. }//febeViewInstallDir()
  322.  
  323. function febeCheckBuDestDir(){
  324.     if(document.getElementById("DestDirID") && document.getElementById("DestDirID").value != ""){
  325.         document.getElementById("febeviewbudirbtnID").disabled = false;
  326.     }else{
  327.         document.getElementById("febeviewbudirbtnID").disabled = true;
  328.     }//if
  329.     return true;
  330. }//febeCheckBuDestDir()
  331.  
  332. function febeDisableOpts(){
  333.     document.getElementById("clearwarn_id").disabled = !document.getElementById("clearDestDir_id").checked;
  334.     document.getElementById("maxBuDirsLabelID").disabled = !document.getElementById("useTimestampedDir_id").checked;
  335.     document.getElementById("maxBuDirsID").disabled = !document.getElementById("useTimestampedDir_id").checked;
  336.     febePlatform = febeGetPlatform();
  337.     if(febePlatform == 1){
  338.         document.getElementById("febedisablepermchk").disabled = true;
  339.         document.getElementById("febesetpermissionsbtn").disabled = true;
  340.     }else{
  341.         document.getElementById("febedisablepermchk").disabled = false;
  342.         document.getElementById("febesetpermissionsbtn").disabled = false;
  343.     }//if
  344.     return true;
  345. }//febeDisableOpts()
  346.  
  347. function febeRunShellInstallDir(){
  348.   // Open a shell to the install dir
  349.     var file = Components.classes["@mozilla.org/file/local;1"]
  350.             .createInstance(Components.interfaces.nsILocalFile);
  351.     switch(febePlatform){
  352.     
  353.     case 1:
  354.         file.initWithPath("C:");
  355.         file.append("windows");
  356.         file.append("system32");
  357.         file.append("cmd.exe")
  358.         var process = Components.classes["@mozilla.org/process/util;1"]
  359.             .createInstance(Components.interfaces.nsIProcess);
  360.         process.init(file);
  361.     
  362.         var FEBEdir = Components.classes["@mozilla.org/extensions/manager;1"]
  363.             .getService(Components.interfaces.nsIExtensionManager)
  364.             .getInstallLocation(FEBE_GUID)
  365.             .getItemLocation(FEBE_GUID);
  366.  
  367.         var argv = ["/K","cd",FEBEdir.path];
  368.         var prefName = "extensions.febe.debugMode";
  369.         febeDebugMode = febePrefs.getBoolPref(prefName);
  370.         if(febeDebugMode == true){
  371.             var style = "<style>font-family: courier; font-size: 8pt;</style>";
  372.             var tmp = style+file.path+" /K\n";
  373.             tmp += style+"cd "+FEBEdir.path+"\n"
  374.             febeAlert(tmp);
  375.         }//if
  376.         process.run(true, argv, argv.length);    
  377.         break;
  378.     case 2:
  379.         file.initWithPath("/");
  380.         file.append("bin");
  381.         file.append("sh")
  382.         var process = Components.classes["@mozilla.org/process/util;1"]
  383.             .createInstance(Components.interfaces.nsIProcess);
  384.         process.init(file);
  385.     
  386.         var FEBEdir = Components.classes["@mozilla.org/extensions/manager;1"]
  387.             .getService(Components.interfaces.nsIExtensionManager)
  388.             .getInstallLocation(FEBE_GUID)
  389.             .getItemLocation(FEBE_GUID);
  390.        
  391.         var arg = 'cd "'+FEBEdir.path+'";/usr/bin/xterm -e sh';
  392.         var argv = ["-c",arg];
  393.         process.run(true, argv, argv.length);    
  394.         break;
  395.     case 3:
  396.       // Create the tmp file to store the batch file
  397.         febeGetTmpDirectory(true);
  398.         if(!febeTmpDir.exists()){
  399.             febeTmpDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
  400.         }//if
  401.         
  402.       // Get pointer to FEBE install dir
  403.         var FEBEdir = Components.classes["@mozilla.org/extensions/manager;1"]
  404.             .getService(Components.interfaces.nsIExtensionManager)
  405.             .getInstallLocation(FEBE_GUID)
  406.             .getItemLocation(FEBE_GUID);
  407.             
  408.       // Create a batch file to launch shell
  409.         var febeMacLaunch = febeTmpDir.clone();
  410.         febeMacLaunch.append("macinstalldir.sh");
  411.         if(febeMacLaunch.exists()){febeMacLaunch.remove(true);}
  412.         febeMacLaunch.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0777);
  413.     
  414.         var febeMacShell = Components.classes["@mozilla.org/network/file-output-stream;1"]
  415.             .createInstance(Components.interfaces.nsIFileOutputStream);
  416.         febeMacShell.init(febeMacLaunch, 0x02 | 0x08 | 0x20, 0777, 0); // write, create, truncate
  417.     
  418.         var charset = "UTF-8";
  419.         var osBatchFile = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
  420.                      .createInstance(Components.interfaces.nsIConverterOutputStream);
  421.         osBatchFile.init(febeMacShell, charset, 4096, 0x0000);
  422.     
  423.     // Build the batch file
  424.         var batchlines = [];
  425.         batchlines.push("cd \'"+FEBEdir.path+"\'");
  426.         batchlines.push("pwd");
  427.         batchlines.push("/bin/sh");
  428.         
  429.         febeNLchar = "\n";
  430.         osBatchFile.writeString(batchlines.join(febeNLchar));
  431.         osBatchFile.close();
  432.         
  433.     // Change the permissions
  434.         var chmodfile = Components.classes["@mozilla.org/file/local;1"]
  435.             .createInstance(Components.interfaces.nsILocalFile);    
  436.         chmodfile.initWithPath("/");
  437.         chmodfile.append("bin");
  438.         chmodfile.append("chmod");
  439.         var process = Components.classes["@mozilla.org/process/util;1"]
  440.                         .createInstance(Components.interfaces.nsIProcess);
  441.         process.init(chmodfile);
  442.  
  443.         var argv = ["0777",febeMacLaunch.path];
  444.     
  445.         process.run(true, argv, argv.length);
  446.     
  447.     // Run the batch file
  448.         file.initWithPath("/");
  449.         file.append("usr");
  450.         file.append("bin")
  451.         file.append("open")
  452.         var process = Components.classes["@mozilla.org/process/util;1"]
  453.         .createInstance(Components.interfaces.nsIProcess);
  454.         process.init(file);
  455.  
  456.         /*  This is want it to do, but it just don't work ...
  457.             Run the batch file that cd's to the intall dir and shells
  458.             
  459.         var argv = ["-a","/Applications/Utilities/Terminal.app","\'"+febeMacLaunch.path+"'"];
  460.         */
  461.         
  462.         // So open a generic terminal windw
  463.         var argv = ["/Applications/Utilities/Terminal.app"];
  464.         process.run(true, argv, argv.length);    
  465.         break;
  466.     }//switch
  467.     return true;
  468. }//febeRunShellInstallDir()
  469.  
  470. function febeRunShellTmpDir(){
  471.   // Open a shell to the tmp dir
  472.     febeGetTmpDirectory(true);
  473.     if (!febeTmpDir.exists()){
  474.         febeTmpDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
  475.     }//if
  476.         
  477.     var file = Components.classes["@mozilla.org/file/local;1"]
  478.         .createInstance(Components.interfaces.nsILocalFile);
  479.         
  480.     switch(febePlatform){
  481.     case 1:
  482.         file.initWithPath("C:");
  483.         file.append("windows");
  484.         file.append("system32");
  485.         file.append("cmd.exe")
  486.         var process = Components.classes["@mozilla.org/process/util;1"]
  487.                         .createInstance(Components.interfaces.nsIProcess);
  488.         process.init(file);
  489.  
  490.         var argv = ["/K","cd",febeTmpDir.path];
  491.         process.run(true, argv, argv.length);
  492.         break;    
  493.     case 2:
  494.         file.initWithPath("/");
  495.         file.append("bin");
  496.         file.append("sh")
  497.         var process = Components.classes["@mozilla.org/process/util;1"]
  498.             .createInstance(Components.interfaces.nsIProcess);
  499.         process.init(file);
  500.        
  501.         var arg = 'cd "'+febeTmpDir.path+'";/usr/bin/xterm -e sh';
  502.         var argv = ["-c",arg];
  503.         process.run(true, argv, argv.length);    
  504.         break;
  505.     case 3:
  506.       // Create the tmp file to store the batch file
  507.         febeGetTmpDirectory(true);
  508.         if(!febeTmpDir.exists()){
  509.             febeTmpDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
  510.         }//if
  511.             
  512.       // Create a batch file to launch shell
  513.         var febeMacLaunch = febeTmpDir.clone();
  514.         febeMacLaunch.append("mactmpdir.sh");
  515.         if(febeMacLaunch.exists()){febeMacLaunch.remove(true);}
  516.         febeMacLaunch.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0777);
  517.     
  518.         var febeMacShell = Components.classes["@mozilla.org/network/file-output-stream;1"]
  519.             .createInstance(Components.interfaces.nsIFileOutputStream);
  520.         febeMacShell.init(febeMacLaunch, 0x02 | 0x08 | 0x20, 0777, 0); // write, create, truncate
  521.     
  522.         var charset = "UTF-8";
  523.         var osBatchFile = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
  524.                      .createInstance(Components.interfaces.nsIConverterOutputStream);
  525.         osBatchFile.init(febeMacShell, charset, 4096, 0x0000);
  526.     
  527.     // Build the batch file
  528.         var batchlines = [];
  529.         batchlines.push("cd \'"+febeTmpDir.path+"\'");
  530.         batchlines.push("pwd");
  531.         batchlines.push("/bin/sh");
  532.         
  533.         febeNLchar = "\n";
  534.         osBatchFile.writeString(batchlines.join(febeNLchar));
  535.         osBatchFile.close();
  536.         
  537.     // Change the permissions
  538.         var chmodfile = Components.classes["@mozilla.org/file/local;1"]
  539.             .createInstance(Components.interfaces.nsILocalFile);    
  540.         chmodfile.initWithPath("/");
  541.         chmodfile.append("bin");
  542.         chmodfile.append("chmod");
  543.         var process = Components.classes["@mozilla.org/process/util;1"]
  544.                         .createInstance(Components.interfaces.nsIProcess);
  545.         process.init(chmodfile);
  546.  
  547.         var argv = ["0777",febeMacLaunch.path];
  548.     
  549.         process.run(true, argv, argv.length);
  550.     
  551.     // Run the batch file
  552.         file.initWithPath("/");
  553.         file.append("usr");
  554.         file.append("bin")
  555.         file.append("open")
  556.         var process = Components.classes["@mozilla.org/process/util;1"]
  557.         .createInstance(Components.interfaces.nsIProcess);
  558.         process.init(file);
  559.  
  560.         /*  This is want it to do, but it just don't work ...
  561.             Run the batch file that cd's to the intall dir and shells
  562.             
  563.         var argv = ["-a","/Applications/Utilities/Terminal.app","\'"+febeMacLaunch.path+"'"];
  564.         */
  565.         
  566.         // So open a generic terminal windw
  567.         var argv = ["/Applications/Utilities/Terminal.app"];
  568.         process.run(true, argv, argv.length);    
  569.         break;
  570.     }//switch
  571.     return true;
  572. }//febeRunShellTmpDir()
  573.  
  574. function febeCloseButtonEtc(){
  575.   // Show close button for Mac OS X users because they don't get buttons for <prefwindow>
  576.     if(febePlatform == 3){
  577.         document.getElementById("febeMacAcceptBtn").hidden = false;
  578.     }//if
  579.     
  580.     // Set text direction
  581.     var textdir = document.getElementById("febeTextDir").value;
  582.     if(!textdir){textdir = "ltr";}
  583.     var prefName = "extensions.febe.orientation";
  584.     febePrefs.setCharPref(prefName,textdir);
  585.     return true;
  586. }//febeCloseButtonEtc()
  587.     
  588.     //var features = "chrome,titlebar,toolbar,centerscreen,modal,resizable";
  589.     //openDialog("chrome://febe/content/febeOptions.xul", "FEBE Options" features);
  590.     //febeOptions()
  591.  
  592. function openPreferences(paneID)
  593. {
  594.   var features = "chrome,titlebar,toolbar,centerscreen,resizable";
  595.  
  596.   var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  597.                      .getService(Components.interfaces.nsIWindowMediator);
  598.   var win = wm.getMostRecentWindow("Browser:Preferences");
  599.   if (win) {
  600.     win.focus();
  601.     if (paneID) {
  602.       var pane = win.document.getElementById(paneID);
  603.       win.document.documentElement.showPane(pane);
  604.     }
  605.   }
  606.   else
  607.     openDialog("chrome://febe/content/febeOptions.xul", 
  608.     "FEBE Options", features, paneID);
  609. }
  610.  
  611. //alert("febeOptions.js loaded");
  612.